package wangjg.security.http;

import javax.servlet.http.HttpServletRequest;

import wangjg.security.core.LoginModule;

/**
 * 一个登陆模块的默认实现
 * @author wangjg
 *
 */
public class HttpLoginModule implements LoginModule{
	public static final String USER_SESSION_KEY = "js-user";
	
	public HttpLoginModule() {
	}

	public Object login() {
		HttpServletRequest request = HttpContext.getRequest();
		Object user = request.getSession().getAttribute(USER_SESSION_KEY);
		return user;
	}

	public Object logout() {
		HttpServletRequest request=HttpContext.getRequest();
		Object user = request.getSession().getAttribute(USER_SESSION_KEY);
		request.getSession().removeAttribute(USER_SESSION_KEY);
		return user;
	}

}
